﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data.Odbc;
using System.Data.OleDb;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("Register.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String CS = ConfigurationManager.ConnectionStrings["myDBConnection"].ConnectionString;
        using (SqlConnection myConnection = new SqlConnection(CS))
        {
            myConnection.Open();
            string GetuserID = "select count(*) from customer_new where userID ='" + TextBoxUserID.Text + "'";
            SqlCommand command = new SqlCommand(GetuserID, myConnection);
            int temp = Convert.ToInt32(command.ExecuteScalar().ToString());
            

            if (temp == 1)
            {
               
                string CheckPassword = " select password from customer_new where userID ='" + TextBoxUserID.Text + "'";
                SqlCommand Passwordcommand = new SqlCommand(CheckPassword, myConnection);
                string password = Passwordcommand.ExecuteScalar().ToString();

                if (password == TextBoxPassword.Text)
                {
                    Response.Redirect("AfterLoginFpage.aspx");
                }
                else
                {
                    Response.Write("Login Failed");
                }

            }
            myConnection.Close();
        }
    }
}